package Service;

import java.util.ArrayList;
import java.util.List;

import dao.CompetitionDao;
import pojo.Competition;
import pojo.PageBean;

public class CompetitionService {
	CompetitionDao cdao;
	public PageBean<Competition> show(int currentPage,int pageSize) {
		cdao = new CompetitionDao();
		PageBean<Competition> pb = new PageBean<Competition>();
		pb.setList(cdao.PageData(currentPage, pageSize));
		pb.setTotal(cdao.getTotal());
		int totalPage=(cdao.getTotal()%pageSize==0)?(cdao.getTotal()/pageSize):(cdao.getTotal()/pageSize+1);
		pb.setTotalPage(totalPage);
		pb.setCurrentPage(currentPage);
		pb.setPageSize(pageSize);
		return pb;
	}
	public List<Competition> showCompetitionByType(int currentPage,int pageSize,int id){
		cdao = new CompetitionDao();
		List<Competition>list=new ArrayList<Competition>();
		list=cdao.showCompetitionByType(currentPage, pageSize, id);
		return list;
	}
	public int add(Competition p) {
		cdao=new CompetitionDao();
		int flag=cdao.add(p);
		return flag;
	}

}